Change in openvpn[master]: ssl: Clean up type handling in write_string()
A message that is not in the archive (sent off-list or not yet received): gerrit.1761324750000.I3309265edf8d6bea7bd73b21eef589a92ede6e0a@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
to review the following change.
Change subject: ssl: Clean up type handling in write_string()
......................................................................
ssl: Clean up type handling in write_string()
Make better checks for the maxlen input value.
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/1
src/openvpn/ssl.c +9 -8
@@ -1781,20 +1781,16 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -static bool write_string (struct buffer *buf,const char *str,const int maxlen) { -const int len =strlen (str) +1 ; -if (len <1 || (maxlen >=0 && len > maxlen)) +const size_t len =strlen (str) +1 ; +const size_t real_maxlen = (maxlen >=0 && maxlen <=UINT16_MAX ) ? (size_t )maxlen :UINT16_MAX ; +if (len <2 || len > real_maxlen) {return false; } -if (!buf_write_u16 (buf, len)) +if (!buf_write_u16 (buf, (uint16_t )len)) {return false; }
@@ -1834,6 +1830,11 @@return len; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static char *read_string_alloc (struct buffer *buf) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
Change subject: ssl: Clean up type handling in write_string()
......................................................................
Patch Set 3: Code-Review-2
(1 comment)
File src/openvpn/ssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1300/comment/605092ec_e5cac272?usp=email :
PS3, Line 1788: if (len < 2 || len > real_maxlen)
changing this from "< 1" to "< 2" is surprising, and I think, not correct - we can and do write empty strings (len=1)...?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 30 Oct 2025 19:27:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
to look at the new patch set (#4).
Change subject: ssl: Clean up type handling in write_string()
......................................................................
ssl: Clean up type handling in write_string()
Make better checks for the maxlen input value.
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/4
src/openvpn/ssl.c +9 -8
@@ -1780,20 +1780,16 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -static bool write_string (struct buffer *buf,const char *str,const int maxlen) { -const int len =strlen (str) +1 ; -if (len <1 || (maxlen >=0 && len > maxlen)) +const size_t len =strlen (str) +1 ; +const size_t real_maxlen = (maxlen >=0 && maxlen <=UINT16_MAX ) ? (size_t )maxlen :UINT16_MAX ; +if (len > real_maxlen) {return false; } -if (!buf_write_u16 (buf, len)) +if (!buf_write_u16 (buf, (uint16_t )len)) {return false; }
@@ -1833,6 +1829,11 @@return len; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static char *read_string_alloc (struct buffer *buf) {
Signature · 15 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a Gerrit-Change-Number: 1300 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld <[email protected]...> Gerrit-Reviewer: cron2 <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]> Gerrit-Attention: plaisthos <[email protected]...> Gerrit-Attention: flichtenheld <[email protected]...>
Attention is currently required from: cron2, plaisthos.
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
Change subject: ssl: Clean up type handling in write_string()
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/ssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1300/comment/24c81aca_9a5c48f2?usp=email :
PS3, Line 1788: if (len < 2 || len > real_maxlen)
Quoted 1 line
changing this from "< 1" to "< 2" is surprising, and I think, not correct - we can and do write empt […]
Right, removed the check completely.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Mon, 03 Nov 2025 12:04:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
Change subject: ssl: Clean up type handling in write_string()
......................................................................
Patch Set 4: Code-Review+2
(1 comment)
File src/openvpn/ssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1300/comment/00f9633e_e49112f5?usp=email :
PS3, Line 1788: if (len < 2 || len > real_maxlen)
Quoted 1 line
Right, removed the check completely.
Indeed. If strlen(str) is 0, len == 1, so len < 1 can just not happen anymore.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 04 Nov 2025 09:19:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
PATCH v4 1/1 ssl: Clean up type handling in write_string()
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Make better checks for the maxlen input value.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1300
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1300
This mail reflects revision 4 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/ssl.c +9 -8
@@ -1780,20 +1780,16 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -static bool write_string (struct buffer *buf,const char *str,const int maxlen) { -const int len =strlen (str) +1 ; -if (len <1 || (maxlen >=0 && len > maxlen)) +const size_t len =strlen (str) +1 ; +const size_t real_maxlen = (maxlen >=0 && maxlen <=UINT16_MAX ) ? (size_t )maxlen :UINT16_MAX ; +if (len > real_maxlen) {return false; } -if (!buf_write_u16 (buf, len)) +if (!buf_write_u16 (buf, (uint16_t )len)) {return false; }
@@ -1833,6 +1829,11 @@return len; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static char *read_string_alloc (struct buffer *buf) {
[Openvpn-devel] [PATCH applied] Re: ssl: Clean up type handling in write_string()
The +2 is already a few days old, but it needed the prerequisites to apply (due to the #pragma moving around).
Change still looks good, passes all BB tests, smoke test on Linux passed as well.
Your patch has been applied to the master branch.
commit 2a4b12f5a732202be99c6f5412c23128126da3cc
Author: Frank Lichtenheld Date: Tue Nov 4 10:19:35 2025 +0100
ssl: Clean up type handling in write_string()
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1300
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34191.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
Change subject: ssl: Clean up type handling in write_string()
......................................................................
Patch Set 5: Code-Review+2
(1 comment)
File src/openvpn/ssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1300/comment/316cab45_6e3be2a4?usp=email :
PS5, Line 1787: const size_t real_maxlen = (maxlen >= 0 && maxlen <= UINT16_MAX) ? (size_t)maxlen : UINT16_MAX;
```suggestion
const size_t real_maxlen = (maxlen >= 0 && maxlen <= UINT16_MAX) ? (size_t)maxlen : UINT16_MAX;
```--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 11 Nov 2025 11:03:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
Change subject: ssl: Clean up type handling in write_string()
......................................................................
Patch Set 5:
(1 comment)
File src/openvpn/ssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1300/comment/37ea3b83_e5eb84eb?usp=email :
PS5, Line 1787: const size_t real_maxlen = (maxlen >= 0 && maxlen <= UINT16_MAX) ? (size_t)maxlen : UINT16_MAX;
Quoted 1 line
```suggestion […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 11 Nov 2025 11:49:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
to look at the new patch set (#6).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.
Change subject: ssl: Clean up type handling in write_string()
......................................................................
ssl: Clean up type handling in write_string()
Make better checks for the maxlen input value.
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/6
src/openvpn/ssl.c +9 -8
@@ -1780,20 +1780,16 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -static bool write_string (struct buffer *buf,const char *str,const int maxlen) { -const int len =strlen (str) +1 ; -if (len <1 || (maxlen >=0 && len > maxlen)) +const size_t len =strlen (str) +1 ; +const size_t real_maxlen = (maxlen >=0 && maxlen <=UINT16_MAX ) ? (size_t )maxlen :UINT16_MAX ; +if (len > real_maxlen) {return false; } -if (!buf_write_u16 (buf, len)) +if (!buf_write_u16 (buf, (uint16_t )len)) {return false; }
@@ -1833,6 +1829,11 @@return len; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static char *read_string_alloc (struct buffer *buf) {
Signature · 14 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a Gerrit-Change-Number: 1300 Gerrit-PatchSet: 6 Gerrit-Owner: flichtenheld <[email protected]...> Gerrit-Reviewer: cron2 <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]> Gerrit-Attention: flichtenheld <[email protected]...>
cron2 has uploaded a new patch set (#7) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2, Code-Review+2 by plaisthos
Change subject: ssl: Clean up type handling in write_string()
......................................................................
ssl: Clean up type handling in write_string()
Make better checks for the maxlen input value.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1300
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34191.html
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/00/1300/7
src/openvpn/ssl.c +9 -8
@@ -1780,20 +1780,16 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -static bool write_string (struct buffer *buf,const char *str,const int maxlen) { -const int len =strlen (str) +1 ; -if (len <1 || (maxlen >=0 && len > maxlen)) +const size_t len =strlen (str) +1 ; +const size_t real_maxlen = (maxlen >=0 && maxlen <=UINT16_MAX ) ? (size_t )maxlen :UINT16_MAX ; +if (len > real_maxlen) {return false; } -if (!buf_write_u16 (buf, len)) +if (!buf_write_u16 (buf, (uint16_t )len)) {return false; }
@@ -1833,6 +1829,11 @@return len; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static char *read_string_alloc (struct buffer *buf) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email )
Change subject: ssl: Clean up type handling in write_string()
......................................................................
ssl: Clean up type handling in write_string()
Make better checks for the maxlen input value.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1300
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34191.html
---
M src/openvpn/ssl.c
1 file changed, 9 insertions(+), 8 deletions(-)
src/openvpn/ssl.c +9 -8
@@ -1780,20 +1780,16 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -static bool write_string (struct buffer *buf,const char *str,const int maxlen) { -const int len =strlen (str) +1 ; -if (len <1 || (maxlen >=0 && len > maxlen)) +const size_t len =strlen (str) +1 ; +const size_t real_maxlen = (maxlen >=0 && maxlen <=UINT16_MAX ) ? (size_t )maxlen :UINT16_MAX ; +if (len > real_maxlen) {return false; } -if (!buf_write_u16 (buf, len)) +if (!buf_write_u16 (buf, (uint16_t )len)) {return false; }
@@ -1833,6 +1829,11 @@return len; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static char *read_string_alloc (struct buffer *buf) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1300?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3309265edf8d6bea7bd73b21eef589a92ede6e0a
Gerrit-Change-Number: 1300
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>